package com.chen.learnknowledge.service.impl;

import com.chen.learnknowledge.dao.EpmloyeeDao;
import com.chen.learnknowledge.entity.Employee;
import com.chen.learnknowledge.service.EmployeeService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    EpmloyeeDao epmloyeeDao;

    @Override
    public Long addEmpOne(Employee employee) {
        Long count = epmloyeeDao.addEmpOne(employee);
        return count;
    }

    //批量新增
    @Override
    public void addEmps(List<Employee> employees) {
        epmloyeeDao.addEmps(employees);
    }

    //根据id获取
    @Override
    public Employee getEmpById(Integer id) {
       Employee employee = epmloyeeDao.getEmpById(id);
        return employee;
    }


    //更新emp
    @Override
    public Boolean updateEmp(Employee employee) {
        Boolean isUpdate = epmloyeeDao.updateEmp(employee);
        return isUpdate;
    }

    //删除
    @Override
    public Integer deleteEmpById(Integer id) {
        Integer isDelete = epmloyeeDao.deleteEmpById(id);
        return isDelete;
    }

    //分页查询
    @Override
    public List<Employee> getPageList(Integer pageSize, Integer pageNum, String name) {

        PageHelper.startPage(pageNum,pageSize);
        List<Employee> employeeList = epmloyeeDao.getPageList(name);
        return employeeList;
    }
}
